package com.niit.spark.sql.test

import org.apache.spark.sql.functions.col
import org.apache.spark.sql.{DataFrame, SparkSession}

/**
 * Date:2025/5/16
 * Author：Ys
 * Description:
 */
object CastColumn {

  def main(args: Array[String]): Unit = {
    val spark: SparkSession = SparkSession.builder().appName("CastColumn").master("local[*]").getOrCreate()
    spark.sparkContext.setLogLevel("ERROR")
    val df: DataFrame = spark.read.option("header", "true").csv("input/sql/employees2.csv")

    df.withColumn("salary",col("salary").cast("double")).show()


    spark.stop()

  }

}
